package com.ly.common.core.domain.entity;

import java.util.Date;
import java.util.List;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ly.common.annotation.Excel;
import com.ly.common.annotation.Excels;
import com.ly.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * 用户对象 sys_user
 *
 * @author
 */
@ApiModel ( value = "用户", description = "用户" )
@EqualsAndHashCode ( callSuper = true )
@Accessors
@Data
@TableName ( "sys_user" )
public class SysUser extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * 用户ID
     */
    @Excel ( name = "用户序号", cellType = Excel.ColumnType.NUMERIC, prompt = "用户编号" )
    @TableId ( value = "user_id", type = IdType.INPUT )
    @ApiModelProperty ( value = "用户ID" )
    private String userId;

    /**
     * 部门ID
     */
    @Excel ( name = "部门编号", type = Excel.Type.IMPORT )
    @TableField ( value = "dept_id" )
    @ApiModelProperty ( value = "部门ID" )
    private String deptId;

    /**
     * 用户账号
     */
    @Excel ( name = "登录名称" )
    @TableField ( value = "user_name" )
    @ApiModelProperty ( value = "用户账号" )
    private String userName;

    /**
     * 用户昵称
     */
    @Excel ( name = "用户名称" )
    @TableField ( value = "nick_name" )
    @ApiModelProperty ( value = "用户昵称" )
    private String nickName;

    /**
     * 用户邮箱
     */
    @Excel ( name = "用户邮箱" )
    @TableField ( value = "email" )
    @ApiModelProperty ( value = "用户邮箱" )
    private String email;

    /**
     * 手机号码
     */
    @Excel ( name = "手机号码" )
    @TableField ( value = "phonenumber" )
    @ApiModelProperty ( value = "手机号码" )
    private String phonenumber;

    /**
     * 用户性别
     */
    @Excel ( name = "用户性别", readConverterExp = "0=男,1=女,2=未知" )
    @TableField ( value = "sex" )
    @ApiModelProperty ( value = "用户性别" )
    private String sex;

    /**
     * 用户头像
     */
    @TableField ( value = "avatar" )
    @ApiModelProperty ( value = "用户头像" )
    private String avatar;

    /**
     * 密码
     */
    @TableField ( value = "password" )
    @ApiModelProperty ( value = "密码" )
    private String password;

    /**
     * 盐加密
     */
    @TableField ( exist = false )
    private String salt;

    /**
     * 帐号状态（0正常 1停用）
     */
    @Excel ( name = "帐号状态", readConverterExp = "0=正常,1=停用" )
    @TableField ( value = "status" )
    @ApiModelProperty ( value = "帐号状态（0正常 1停用）" )
    private String status;

    /**
     * 删除标志（0代表存在 2代表删除）
     */
    @TableField ( value = "del_flag" )
    private String delFlag;

    /**
     * 最后登录IP
     */
    @Excel ( name = "最后登录IP", type = Excel.Type.EXPORT )
    @TableField ( value = "login_ip" )
    @ApiModelProperty ( value = "最后登录IP" )
    private String loginIp;

    /**
     * 最后登录时间
     */
    @Excel ( name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Excel.Type.EXPORT )
    @TableField ( value = "login_date" )
    @ApiModelProperty ( value = "最后登录时间" )
    private Date loginDate;


    /**
     * QQ号
     */
    @Excel ( name = "QQ号" )
    @TableField ( value = "qq" )
    @ApiModelProperty ( value = "QQ号" )
    private String qq;

    /**
     * 微信号
     */
    @Excel ( name = "微信号" )
    @TableField ( value = "we_char_num" )
    @ApiModelProperty ( value = "微信号" )
    private String weCharNum;

    /**
     * 联系地址
     */
    @Excel ( name = "联系地址" )
    @TableField ( value = "address" )
    @ApiModelProperty ( value = "联系地址" )
    private String address;

    /**
     * 员工状态,1:实习;2:试用期;3:已转正;4:试用不合格;5:已辞退;6:自愿离职;7:黑名单;
     */
    @Excel ( name = "员工状态,1:实习;2:试用期;3:已转正;4:试用不合格;5:已辞退;6:自愿离职;7:黑名单" )
    @TableField ( value = "staff_status" )
    @ApiModelProperty ( value = "员工状态,1:实习;2:试用期;3:已转正;4:试用不合格;5:已辞退;6:自愿离职;7:黑名单" )
    private Integer staffStatus;

    /**
     * 直属上级
     */
    @Excel ( name = "直属上级" )
    @TableField ( value = "parent_id" )
    @ApiModelProperty ( value = "直属上级" )
    private String parentId;

    /**
     * 入职日期
     */
    @JsonFormat ( pattern = "yyyy-MM-dd" )
    @Excel ( name = "入职日期", width = 30, dateFormat = "yyyy-MM-dd" )
    @TableField ( value = "emp_time" )
    @ApiModelProperty ( value = "入职日期" )
    private Date empTime;

    /**
     * 离职日期
     */
    @JsonFormat ( pattern = "yyyy-MM-dd" )
    @Excel ( name = "离职日期", width = 30, dateFormat = "yyyy-MM-dd" )
    @TableField ( value = "res_time" )
    @ApiModelProperty ( value = "离职日期" )
    private Date resTime;

    /**
     * 工号
     */
    @Excel ( name = "工号" )
    @TableField ( value = "jod_number" )
    @ApiModelProperty ( value = "工号" )
    private String jodNumber;

    /**
     * 身份证号码
     */
    @Excel ( name = "身份证号码" )
    @TableField ( value = "id_card" )
    @ApiModelProperty ( value = "身份证号码" )
    private String idCard;

    /**
     * 出生日期
     */
    @Excel ( name = "出生日期" )
    @TableField ( value = "birthday_time" )
    @ApiModelProperty ( value = "出生日期" )
    private String birthdayTime;

    /**
     * 民族
     */
    @Excel ( name = "民族" )
    @TableField ( value = "nation" )
    @ApiModelProperty ( value = "民族" )
    private String nation;

    /**
     * 政治面貌
     */
    @Excel ( name = "政治面貌" )
    @TableField ( value = "political" )
    @ApiModelProperty ( value = "政治面貌" )
    private String political;

    /**
     * 婚否;1:是;2:否
     */
    @Excel ( name = "婚否;1:是;2:否" )
    @TableField ( value = "marriage" )
    @ApiModelProperty ( value = "婚否;1:是;2:否" )
    private Integer marriage;

    /**
     * 银行
     */
    @Excel ( name = "银行" )
    @TableField ( value = "bank" )
    @ApiModelProperty ( value = "银行" )
    private String bank;

    /**
     * 银行账户
     */
    @Excel ( name = "银行账户" )
    @TableField ( value = "bank_num" )
    @ApiModelProperty ( value = "银行账户" )
    private String bankNum;

    /**
     * 收款人姓名
     */
    @Excel ( name = "收款人姓名" )
    @TableField ( value = "bank_name" )
    @ApiModelProperty ( value = "收款人姓名" )
    private String bankName;

    /**
     * 调休标准天数
     */
    @Excel ( name = "调休标准天数" )
    @TableField ( value = "rest_sta" )
    @ApiModelProperty ( value = "调休标准天数" )
    private Integer restSta;

    /**
     * 事假标准天数
     */
    @Excel ( name = "事假标准天数" )
    @TableField ( value = "personal_leave" )
    @ApiModelProperty ( value = "事假标准天数" )
    private Integer personalLeave;

    /**
     * 病假标准天数
     */
    @Excel ( name = "病假标准天数" )
    @TableField ( value = "sick_leave" )
    @ApiModelProperty ( value = "病假标准天数" )
    private Integer sickLeave;

    /**
     * 年假标准天数
     */
    @Excel ( name = "年假标准天数" )
    @TableField ( value = "year_leave" )
    @ApiModelProperty ( value = "年假标准天数" )
    private Integer yearLeave;

    /**
     * 婚假标准天数
     */
    @Excel ( name = "婚假标准天数" )
    @TableField ( value = "marriage_leave" )
    @ApiModelProperty ( value = "婚假标准天数" )
    private Integer marriageLeave;

    /**
     * 丧假标准天数
     */
    @Excel ( name = "丧假标准天数" )
    @TableField ( value = "funeral_leave" )
    @ApiModelProperty ( value = "丧假标准天数" )
    private Integer funeralLeave;

    /**
     * 产假标准天数
     */
    @Excel ( name = "产假标准天数" )
    @TableField ( value = "maternity_leave" )
    @ApiModelProperty ( value = "产假标准天数" )
    private Integer maternityLeave;

    /**
     * 其他假标准天数
     */
    @Excel ( name = "其他假标准天数" )
    @TableField ( value = "other_leave" )
    @ApiModelProperty ( value = "其他假标准天数" )
    private Integer otherLeave;

    /**
     * 工时单价
     */
    @Excel ( name = "工时单价" )
    @TableField ( value = "hour_price" )
    @ApiModelProperty ( value = "工时单价" )
    private Integer hourPrice;


    /**
     * 紧急联系人
     */
    @Excel ( name = "紧急联系人" )
    @TableField ( value = "emergency_contact" )
    @ApiModelProperty ( value = "紧急联系人" )
    private String emergencyContact;

    /**
     * 紧急联系人关系
     */
    @Excel ( name = "紧急联系人关系" )
    @TableField ( value = "emergency_relation" )
    @ApiModelProperty ( value = "紧急联系人关系" )
    private String emergencyRelation;

    /**
     * 紧急联系人电话
     */
    @Excel ( name = "紧急联系人电话" )
    @TableField ( value = "emergency_tel" )
    @ApiModelProperty ( value = "紧急联系人电话" )
    private String emergencyTel;

    /**
     * 有无子女;1:有;2:无
     */
    @Excel ( name = "有无子女;1:有;2:无" )
    @TableField ( value = "has_children" )
    @ApiModelProperty ( value = "有无子女;1:有;2:无" )
    private Integer hasChildren;


    /**
     * 招聘来源
     */
    @Excel ( name = "招聘来源" )
    @TableField ( value = "recruitment_sources" )
    @ApiModelProperty ( value = "招聘来源" )
    private String recruitmentSources;


    /**
     * 推荐人
     */
    @Excel ( name = "推荐人" )
    @TableField ( value = "recommended_by" )
    @ApiModelProperty ( value = "推荐人" )
    private String recommendedBy;

    /**
     * 工作地点
     */
    @Excel ( name = "工作地点" )
    @TableField ( value = "work_address" )
    @ApiModelProperty ( value = "工作地点" )
    private String workAddress;


    /**
     * 职称
     */
    @Excel ( name = "职称" )
    @TableField ( value = "professional_title" )
    @ApiModelProperty ( value = "职称" )
    private String professionalTitle;


    /**
     * 专业资格
     */
    @Excel ( name = "专业资格" )
    @TableField ( value = "professional_qualification" )
    @ApiModelProperty ( value = "专业资格" )
    private String professionalQualification;


    /**
     * 转正日期
     */
    @Excel ( name = "转正日期" )
    @TableField ( value = "formal_time" )
    @ApiModelProperty ( value = "转正日期" )
    private Date formalTime;


    /**
     * 现通讯地址
     */
    @Excel ( name = "现通讯地址" )
    @TableField ( value = "mailing_address" )
    @ApiModelProperty ( value = "现通讯地址" )
    private String mailingAddress;

    /**
     * 身份证地址
     */
    @Excel ( name = "身份证地址" )
    @TableField ( value = "id_address" )
    @ApiModelProperty ( value = "身份证地址" )
    private String idAddress;

    /**
     * 邮编
     */
    @Excel ( name = "邮编" )
    @TableField ( value = "postal_code" )
    @ApiModelProperty ( value = "邮编" )
    private String postalCode;


    /**
     * 离职原因
     */
    @Excel ( name = "离职原因" )
    @TableField ( value = "res_reason" )
    @ApiModelProperty ( value = "离职原因" )
    private String resReason;

    /**
     * 用户编码
     */
    @Excel ( name = "用户编码" )
    @TableField ( value = "user_code" )
    @ApiModelProperty ( value = "用户编码" )
    private String userCode;

    @Excel ( name = "是否推送金额" )
    @TableField ( value = "is_send" )
    private Integer isSend;

    /**
     * 部门对象
     */
    @Excels ( {
            @Excel ( name = "部门名称", targetAttr = "deptName", type = Excel.Type.EXPORT ),
            @Excel ( name = "部门负责人", targetAttr = "leader", type = Excel.Type.EXPORT )
    } )
    @TableField ( exist = false )
    private SysDept dept;

    /**
     * 角色对象
     */
    @TableField ( exist = false )
    private List<SysRole> roles;

    /**
     * 角色组
     */
    @TableField ( exist = false )
    private String[] roleIds;

    /**
     * 岗位组
     */
    @TableField ( exist = false )
    private String[] postIds;


    /**
     * wuzh
     */
    @TableField ( exist = false )
    private List<UserWorkExperienceEntity> userWorkExperienceEntities;
    @TableField ( exist = false )
    private List<UserEducationalEntity> userEducationalEntities;
    @TableField ( exist = false )
    private List<UserMajorSocialRelationEntity> userMajorSocialRelationEntities;

    public SysUser () {

    }

    public SysUser ( String userId ) {
        this.userId = userId;
    }

    public String getUserId () {
        return userId;
    }

    public void setUserId ( String userId ) {
        this.userId = userId;
    }

    public boolean isAdmin () {
        return isAdmin ( this.userId );
    }

    public static boolean isAdmin ( String userId ) {
        return userId != null && userId != "" && "1".equals ( userId );
    }

    public String getDeptId () {
        return deptId;
    }

    public void setDeptId ( String deptId ) {
        this.deptId = deptId;
    }

    @Size ( min = 0, max = 30, message = "用户昵称长度不能超过30个字符" )
    public String getNickName () {
        return nickName;
    }

    public void setNickName ( String nickName ) {
        this.nickName = nickName;
    }

    @NotBlank ( message = "用户账号不能为空" )
    @Size ( min = 0, max = 30, message = "用户账号长度不能超过30个字符" )
    public String getUserName () {
        return userName;
    }

    public void setUserName ( String userName ) {
        this.userName = userName;
    }

    @Email ( message = "邮箱格式不正确" )
    @Size ( min = 0, max = 50, message = "邮箱长度不能超过50个字符" )
    public String getEmail () {
        return email;
    }

    public void setEmail ( String email ) {
        this.email = email;
    }

    @Size ( min = 0, max = 11, message = "手机号码长度不能超过11个字符" )
    public String getPhonenumber () {
        return phonenumber;
    }

    public void setPhonenumber ( String phonenumber ) {
        this.phonenumber = phonenumber;
    }

    public String getSex () {
        return sex;
    }

    public void setSex ( String sex ) {
        this.sex = sex;
    }

    public String getAvatar () {
        return avatar;
    }

    public void setAvatar ( String avatar ) {
        this.avatar = avatar;
    }

    @JsonIgnore
    @JsonProperty
    public String getPassword () {
        return password;
    }

    public void setPassword ( String password ) {
        this.password = password;
    }

    public String getSalt () {
        return salt;
    }

    public void setSalt ( String salt ) {
        this.salt = salt;
    }

    public String getStatus () {
        return status;
    }

    public void setStatus ( String status ) {
        this.status = status;
    }

    public String getDelFlag () {
        return delFlag;
    }

    public void setDelFlag ( String delFlag ) {
        this.delFlag = delFlag;
    }

    public String getLoginIp () {
        return loginIp;
    }

    public void setLoginIp ( String loginIp ) {
        this.loginIp = loginIp;
    }

    public Date getLoginDate () {
        return loginDate;
    }

    public void setLoginDate ( Date loginDate ) {
        this.loginDate = loginDate;
    }

    public SysDept getDept () {
        return dept;
    }

    public void setDept ( SysDept dept ) {
        this.dept = dept;
    }

    public List<SysRole> getRoles () {
        return roles;
    }

    public void setRoles ( List<SysRole> roles ) {
        this.roles = roles;
    }

    public String[] getRoleIds () {
        return roleIds;
    }

    public void setRoleIds ( String[] roleIds ) {
        this.roleIds = roleIds;
    }

    public String[] getPostIds () {
        return postIds;
    }

    public void setPostIds ( String[] postIds ) {
        this.postIds = postIds;
    }

    @Override
    public String toString () {
        return new ToStringBuilder ( this, ToStringStyle.MULTI_LINE_STYLE )
                .append ( "userId", getUserId () )
                .append ( "deptId", getDeptId () )
                .append ( "userName", getUserName () )
                .append ( "nickName", getNickName () )
                .append ( "email", getEmail () )
                .append ( "phonenumber", getPhonenumber () )
                .append ( "sex", getSex () )
                .append ( "avatar", getAvatar () )
                .append ( "password", getPassword () )
                .append ( "salt", getSalt () )
                .append ( "status", getStatus () )
                .append ( "delFlag", getDelFlag () )
                .append ( "loginIp", getLoginIp () )
                .append ( "loginDate", getLoginDate () )
                .append ( "createBy", getCreateBy () )
                .append ( "createTime", getCreateTime () )
                .append ( "updateBy", getUpdateBy () )
                .append ( "updateTime", getUpdateTime () )
                .append ( "remark", getRemark () )
                .append ( "dept", getDept () )
                .toString ();
    }
}
